function unistall 

%UNISTALL 
%
%   UNISTALL crack targetlink calibration tool unistallation 
%
%   Inputs:
%       -- / --
%
%   Outputs:
%       -- / --
%
%   Syntax:
%       unistall
%
%   Example:
%       -- / --
%
%   See also:
%       -- / --
% 
%   Author(s): Xiaobiao Huang
%   Copyright 2013-2020 The Xiaobiao Studio.
%   $Revision: 1.0.0.0 $  $Date: 17-Sep-2013 22:46:21 $

fileList = {'tl_open_blockdlg',...
            'tl_manage_doc_ctrls',...
            'tl_task_dlg',...
            'tl_isr_dlg' ,...
            'tl_criticalsection_dlg' ,...
            };
        
filePath = which(fileList{1});
delete([fileparts(filePath) '\xscrack.p']);

for ifile = 1: length(fileList)
    filePath = which(fileList{ifile});
    farray = '';
    try
        fid = fopen(filePath,'r+');
        tline = fgets(fid);
        iColumn = 1;
        while ischar(tline)
            farray{iColumn,1} = tline;
            if strfind(tline,'% crack the targetlink calibration')
                removeLineStart = iColumn;
            end
            if strfind(tline,'% end of add crack function')
                removeLineEnd = iColumn;
            end
            iColumn = iColumn + 1;
            tline = fgets(fid);
        end
        newfile = [farray(1:removeLineStart-1); farray(removeLineEnd+2:end)];
        fclose(fid);
        % create new file
        fid = fopen(filePath,'w+');
        for iline = 1 : length(newfile)
            fwrite(fid,newfile{iline});
        end
        fprintf('remove installation from %s successed\n',fileList{ifile});
    catch exception
        fprintf('remove installation from  %s failed: %s\n',fileList{ifile}, exception.message);
    end
end
